package cn.shentianlan.controller;

import cn.shentianlan.criteria.StudentCriteria;
import cn.shentianlan.domain.dto.StudentDTO;
import cn.shentianlan.service.StudentService;
import cn.shentianlan.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author 陈俊源
 * @Description TODO
 * @Date 2021/4/11
 * @Version 1.0
 */
@RestController
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @RequestMapping("/saveOrUpdate")
    public Result saveOrUpdate(StudentDTO studentDTO){
        Result result = studentService.saveOrUpdate(studentDTO);
        return result;
    }

    @RequestMapping("/getStudentById")
    public Result getStudentById(Long id){
        Result result = studentService.getStudentById(id);
        return result;
    }

    @PostMapping("/list")
    public Result findStudentByCriteria(StudentCriteria criteria){
        Result result = studentService.findStudentByCriteria(criteria);
        return result;
    }
}
